package com.vision;

import com.sun.tools.javadoc.JavadocClassReader;
import com.vision.web.annotation.RAP;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
import org.springframework.core.type.filter.AnnotationTypeFilter;
import org.springframework.stereotype.Controller;

import java.lang.annotation.Annotation;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @author zhongchao
 * @title
 * @Date 2017/07/04
 */
public class Main {

    public static final Set<Class> CLASSES = new HashSet<>();

    public static void main(String[] args) {
        String s = VisionApplication.class.getPackage().getName();
        ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(false);
        // scanner.addIncludeFilter(new AnnotationTypeFilter(RestController.class));
        scanner.addIncludeFilter(new AnnotationTypeFilter(RAP.class));
        Set<BeanDefinition> candidateComponents = scanner.findCandidateComponents(s);
        for (BeanDefinition beanDefinition : candidateComponents) {
            try {
                CLASSES.add(Class.forName(beanDefinition.getBeanClassName()));
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
        }
        List<Patent> patents = new ArrayList<>();
        for (Class c : CLASSES) {
            RAP rap = (RAP) c.getAnnotation(RAP.class);
            Patent patent = new Patent();
            patent.setName(rap.methodName());
        }


        System.out.println(candidateComponents);


    }

}
class Patent{
    private String name;
    private String url;
    private String request;
    private String result;
    private List<Patent> children;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getRequest() {
        return request;
    }

    public void setRequest(String request) {
        this.request = request;
    }

    public String getResult() {
        return result;
    }

    public void setResult(String result) {
        this.result = result;
    }

    public List<Patent> getChildren() {
        return children;
    }

    public void setChildren(List<Patent> children) {
        this.children = children;
    }
}
